#include <assert.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
#include "cmd.h"
#include "parse.h"

void read_line(char *line, int size)
{
    read(0,line,size);
}

int main()
{
    test_parse_cmd_1();
    test_parse_cmd_2();
    test_parse_pipe_cmd_1();
    test_parse_pipe_cmd_2();
    test_exec_cmd();
    test_exec_pipe_cmd();
    printf("All test have passed!\n");
    struct cmd comand;
    char line[100];
    while (1) 
    {
        printf(">");
        fflush(stdout);
        read_line(line,100);
        //printf("%s\n",line);
        int cmdc=parse_pipe_cmd(line,&comand);
        //dump_pipe_cmd(cmdc,&comand);
        exec_pipe_cmd(cmdc,&comand);
    }
    return 0;
}